package com.example.myapplication.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.example.myapplication.R;
import com.example.myapplication.adapters.CartAdapter;
import com.example.myapplication.adapters.FoodAdapter;

import static com.example.myapplication.activity.ShopActivity.cartFoods;

public class OrderConfirmActivity extends AppCompatActivity {
    RecyclerView lv_order_food;
    LinearLayout ll_offline;
    LinearLayout ll_online;
    TextView total_amount;
    LinearLayout ll_pay;
    boolean isOnline;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_confirm);
        lv_order_food = findViewById(R.id.lv_order_food);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        lv_order_food.setLayoutManager(linearLayoutManager);
        lv_order_food.setNestedScrollingEnabled(false);
        lv_order_food.setAdapter(new FoodAdapter(cartFoods, R.layout.order_confirm_item, getApplicationContext()));

        ll_offline = findViewById(R.id.ll_offline);
        ll_online = findViewById(R.id.ll_online);
        total_amount = findViewById(R.id.total_amount);
        ll_pay = findViewById(R.id.ll_pay);


        ll_pay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(OrderConfirmActivity.this, OrderFinishActivity.class);
                intent.putExtra("total_amount", getIntent().getStringExtra("total_amount"));
                startActivity(intent);
            }
        });


        isOnline  = false;
        ll_offline.setBackground(getDrawable(R.drawable.border_yellow_chose));
        ll_offline.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                isOnline = false;
                ll_offline.setBackground(getDrawable(R.drawable.border_yellow_chose));
                ll_online.setBackground(getDrawable(R.drawable.shape_corner_gray));
            }
        });

        ll_online.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                isOnline  = true;
                ll_online.setBackground(getDrawable(R.drawable.border_yellow_chose));
                ll_offline.setBackground(getDrawable(R.drawable.shape_corner_gray));
            }
        });


        total_amount.setText(getIntent().getStringExtra("total_amount"));



    }
}